package com.zysdev.zysplayer.utils;


public class TimeUtil {

    /*根据时长格式化称时间文本*/
    public static String duration2Time(int duration) {
        int min = duration / 1000 / 60;
        int sec = duration / 1000 % 60;
        return (min < 10 ? "0" + min : min + "") + ":" + (sec < 10 ? "0" + sec : sec + "");
    }

    public static String secondsToDateFormat(int seconds, int totalSeconds) {
        long hours = seconds / (60 * 60);
        long minutes = (seconds % (60 * 60)) / (60);
        long mSeconds = seconds % (60);

        String sh = "00";
        if (hours > 0) {
            if (hours < 10) {
                sh = "0" + hours;
            } else {
                sh = hours + "";
            }
        }
        String sm = "00";
        if (minutes > 0) {
            if (minutes < 10) {
                sm = "0" + minutes;
            } else {
                sm = minutes + "";
            }
        }

        String ss = "00";
        if (mSeconds > 0) {
            if (mSeconds < 10) {
                ss = "0" + mSeconds;
            } else {
                ss = mSeconds + "";
            }
        }
        if(totalSeconds >= 3600)
        {
            return sh + ":" + sm + ":" + ss;
        }
        return sm + ":" + ss;

    }

}
